<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT type_scheme,sum(cwr_total) as CWR,sum(glsr_total) as GLSR,sum(glr_total) as GLR,sum(ohsr_total) as OHSR,district_id FROM `tbl_dtls_q1_main` where `district_id` = ".$distId." group by `type_scheme`";
//echo $sqlReport;
$queryReport = mysql_query($sqlReport);

?>
<table border="0" width="809" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">Scheme wise and storage structure 
		wise information on reservoir capacity and their sufficiency</font></span></td>
	</tr>
	
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="809" cellspacing="0" cellpadding="0" height="47" bgcolor="#C5D8EB">
			<tr>
				
				<td width="123" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
				<b>Type of Scheme</b></font></td>
				<td width="109" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Type of Reservoir</b></font></td>
				<td width="99" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>No. of 
				Reservoirs (No.)</b></font></td>
				<td width="113" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Installed Capacity 
				(KL)</b></font></td>
				<td width="116" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Current Population 
				served 2010</b></font></td>
				<td align="center" width="117">
				<font style="font-size: 8.5pt" face="Verdana"><b>Required storage 
				capacity (KL)</b></font></td>
				<td width="116" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Sufficiency of 
				installed storage capacity (%)</b></font></td>
			</tr>
		</table>		</td>
	</tr>
	<tr>
		<td>
		<table border="1" width="809" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
		<?php
			while($rowReport = mysql_fetch_array($queryReport)) {
			$storageCWR=0;
			$storageGLR=0;
			$storageGLSR=0;
			$storageOHSR=0;
			if(($rowReport['district_id']==389) || ($rowReport['district_id']==390) || ($rowReport['district_id']==398) || ($rowReport['district_id']==391) || ($rowReport['district_id']==392) || ($rowReport['district_id']==401) || ($rowReport['district_id']==402) || ($rowReport['district_id']==403) || ($rowReport['district_id']==404) || ($rowReport['district_id']==405) || ($rowReport['district_id']==406) || ($rowReport['district_id']==416))
			{
			$lpcd=70;
			}else{
			$lpcd=40;
			}
		?>
			
			
			<?php 
			if($rowReport['CWR'] !=0 || $rowReport['GLR'] !=0 || $rowReport['GLSR'] !=0 || $rowReport['OHSR'] !=0)
			{
			?>
			<tr>
				<td align="left" width="124" rowspan="4" valign="top"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['type_scheme']; ?></font></td>
				<td align="center" width="105"><font face="Verdana" style="font-size: 8.5pt">CWR</font></td>
				<td align="center" width="103"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['CWR'];?></font></td>
				<td align="center" width="112"><font face="Verdana" style="font-size: 8.5pt"><?php 
				
				$a=getStorageSchemeWise($distId,$rowReport['type_scheme'],'CWR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				} 
				
				?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getPopulationStorageWise($distId,$rowReport['type_scheme'],'CWR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td width="117" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $storageCWR=getPopulationStorageWise($distId,$rowReport['type_scheme'],'CWR')*$lpcd/1000; ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php if($storageCWR==0 || $storageCWR==""){echo "0.00"; } else { echo number_format((getStorageSchemeWise($distId,$rowReport['type_scheme'],'CWR')*100)/$storageCWR,2,'.',''); }?></font></td>
			</tr>
			<tr>
				<td align="center" width="105"><font face="Verdana" style="font-size: 8.5pt">GLR</font></td>
				<td align="center" width="103"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['GLR'];?></font></td>
				<td align="center" width="112"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $storageGLR=getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLR')*$lpcd/1000; ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php if($storageGLR==0 || $storageGLR==""){echo "0.00"; } else { echo number_format((getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLR')*100)/$storageGLR,2,'.',''); }?></font></td>
			</tr>
			<tr>
				<td align="center" width="105"><font face="Verdana" style="font-size: 8.5pt">GLSR</font></td>
				<td align="center" width="103"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['GLSR'];?></font></td>
				<td align="center" width="112"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLSR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLSR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $storageGLSR=getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLSR')*$lpcd/1000; ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php if($storageGLSR==0 || $storageGLSR==""){echo "0.00"; } else { echo number_format((getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLSR')*100)/$storageGLSR,2,'.',''); }?></font></td>
			</tr>
			<tr>
				<td align="center" width="105"><font face="Verdana" style="font-size: 8.5pt">OHSR</font></td>
				<td align="center" width="103"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['OHSR'];?></font></td>
				<td align="center" width="112"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getStorageSchemeWise($distId,$rowReport['type_scheme'],'OHSR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php 
				$a=getPopulationStorageWise($distId,$rowReport['type_scheme'],'OHSR');
				if($a=='')
				{
					echo 0;
				}
				else
				{
					echo $a;
				}
				 ?></font></td>
				<td align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $storageOHSR=getPopulationStorageWise($distId,$rowReport['type_scheme'],'OHSR')*$lpcd/1000; ?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php if($storageOHSR==0 || $storageOHSR==""){echo "0.00"; } else { echo number_format((getStorageSchemeWise($distId,$rowReport['type_scheme'],'OHSR')*100)/$storageOHSR,2,'.',''); }?></font></td>
			</tr>
			
			<tr>
				<td colspan="2" bgcolor="#E9E9E9" align="left" width="124"><font face="Verdana" style="font-size: 8.5pt"><b>Total</b></font></td>
				
				<td align="center" bgcolor="#E9E9E9" width="103"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $grandResvtot=$rowReport['CWR']+$rowReport['GLR']+$rowReport['GLSR']+$rowReport['OHSR'];?></b></font></td>
				<td align="center" bgcolor="#E9E9E9" width="112"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $instaltot=getStorageSchemeWise($distId,$rowReport['type_scheme'],'CWR')+getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLR')+getStorageSchemeWise($distId,$rowReport['type_scheme'],'GLSR')+getStorageSchemeWise($distId,$rowReport['type_scheme'],'OHSR'); ?></b></font></td>
				<td align="center" bgcolor="#E9E9E9" width="116"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $currentPop=getPopulationStorageWise($distId,$rowReport['type_scheme'],'CWR')+getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLR')+getPopulationStorageWise($distId,$rowReport['type_scheme'],'GLSR')+getPopulationStorageWise($distId,$rowReport['type_scheme'],'OHSR'); ?></b></font></td>
				<td align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $storagecap=$storageCWR+$storageGLR+$storageGLSR+$storageOHSR;?></b></font></td>
				<td align="center" width="116" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php if($storagecap==0 || $storagecap==""){echo "0.00"; } else { echo number_format(($instaltot*100)/$storagecap,2,'.',''); }?></b></font></td>
			</tr>
			<?php
			}
			?>
			
			<?php 
			//$slNo++;
			
			$grandResv+=$grandResvtot;
			$instGrandTot+=$instaltot;
			$currentpopGrandTot+=$currentPop;
			$storageCapGrandTot+=$storagecap;
			} ?>
			
			<tr>
				<td colspan="2" bgcolor="#E9E9E9" align="left" width="124"><font face="Verdana" style="font-size: 8.5pt"><b>Grand Total</b></font></td>
				
				<td align="center" bgcolor="#E9E9E9" width="103"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $grandResv;//$rowReport['CWR']+$rowReport['GLR']+$rowReport['GLSR']+$rowReport['OHSR']+0;?></b></font></td>
				<td align="center" bgcolor="#E9E9E9" width="112"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $instGrandTot; ?></b></font></td>
				<td align="center" bgcolor="#E9E9E9" width="116"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $currentpopGrandTot; ?></b></font></td>
				<td align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $storageCapGrandTot;?></b></font></td>
				<td align="center" width="116" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php if($storageCapGrandTot==0 || $storageCapGrandTot==""){echo "0.00"; } else { echo number_format(($instGrandTot*100)/$storageCapGrandTot,2,'.',''); }?></b></font></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>



</body>

</html>